package com.niu;

import java.util.LinkedList;
import java.util.List;

/***
 * @ClassName: test
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 15:15 2022/2/3
 * @version : V1.0
 */
public class test {

    static List<String> poker = null;
    public static void main(String[] args) {
        niuniu(3);

    }

    public static void niuniu(int playerNums){
        poker = getPoker();
        System.out.println("庄家的牌是:");
        getCardsByPlayer();
        for (int i = 0; i < playerNums; i++) {
            System.out.println(i+1+"号玩家的牌是:");
            getCardsByPlayer();
        }


    }
    public static List<String> getPoker(){
        String[] pai = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        String[] flower = {"♠", "♥", "♣", "♦"};
        List<String> list = new LinkedList<>();
        for (String s : pai) {
            for (String s1 : flower) {
                list.add(s1 + s);
            }
        }
        return list;
    }

    public static int getCardIndex(int maxIn) {
        int max = maxIn, min = 0;
        int ran2 = (int) (Math.random() * (max - min) + min);
        return ran2;
    }


    public static void dealCards(int index){
        String s = poker.get(index);
        poker.remove(index);

        System.out.print(s+"\t");

    }

    public static void getCardsByPlayer(){
        for (int i = 0; i < 5; i++) {
            int max = getCardIndex(poker.size());
            int cardIndex = getCardIndex(max);
            dealCards(cardIndex);
        }
        System.out.println("");
    }
}
